<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" href="../js/themes/default/peasyui.css">
	<link rel="stylesheet" type="text/css" href="../js/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo/demo.css">
	<link rel="stylesheet" type="text/css" href="../css/dianjia.css"/>
	<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
	<script type="text/javascript" src="../js/template.js"></script>
	<script type="text/javascript" src="../js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../js/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../js/plugins/jquery.datagrid.js"></script>
	<script type="text/javascript">
		var  login;	
		$(function(){
			login = $("#login").dialog({closable:false,
				draggable:false
				});
			});
	</script>
<script type="text/javascript">
$(function(){
	$(".sercapacity3").hide();
	$(".searchButton").click(function(){
		$(".sercapacity3").hide();
		$(this).next(".sercapacity3").show();
	 })
	 $(".sercapacity3 input.djque").click(function(){
	  $(this).parent(".sercapacity3").hide();
	
	})
});

		function memberSure(){
			var sj=$("input[name=memNamecheckbox]:checked").parent().parent().children(1).text();
			var code = sj.substr(0,3);
			var company = sj.substr(3);
			$("#i1").val(code);
			$("#i2").val(company);
			
			$("#cid").val(sj);
		}
		
		function selectOne(dd){
			var memberCheck = $(".memberCheck");
			$.each(memberCheck,function(i,n){
				if(dd ==  n){}
				else{
					n.checked=false;
				}
			});
		}
	
		
		function doAction(){
			var value=document.getElementById("i2").value;
			if(value==''){
				$("#i2").val('公司名称');
				document.getElementById("i2").type='text';
			}
		}
		function getValue(){
			
			$.ajax({
				type:"GET",
		    	async: false,
		   	 	url:"<%=path %>/login/get/user",
		   		data :{"username":$("#i3").val(),"password":$("#i4").val()},
		   		dataType: "json",
		    	success:function(data){
		    	
		    		var num =data.status;
		    		if(num==0){
		    			
		    			window.location.href="BillLayout.jsp?date="+$("#shijian").datebox('getValue')+"&userInfo="+data.data.cuser_id+"&userPwd="+data.data.cUserHand+"&cropInfo="+$("#cid").val(); 
		    			}
			    	}
				});
			
		}
		
		function getCrop(){
			
			
			$.ajax({
				type:"GET",
		    	async: false,
		   	 	url:"<%=path %>/login/get/corp",
		   		data :{"pageSize":$("#pageCount").val(),"pageNum":$("#currPage").val()},
		   		dataType: "json",
		    	success:function(data){
		    		var memArchise=data.data;
		    		var num=memArchise.length;
					if(num!=0){
						$("#totalPages").val(data.total);
				    	$("#ltotalPages").text(data.total);
					}else{
						$("#ltotalPages").val(1);
					}
		      		var beans = {			
						list : memArchise
		      		};
					var html = template('memberList', beans);
					document.getElementById('memberNames').innerHTML =html;	
		    		
			    	}
				});
		}
		
</script>
<script type="text/javascript">	
function fenye(mark){

	 currPage = Number($("#currPage").val());	
     totalPages = Number($("#totalPages").val());
     console.log(currPage+","+totalPages);
	if(mark=="previous"){
		if(currPage==1){	
			alert("已经是首页了！");
		}else{				
			currPage = currPage-1;
			$("#currPage").val(currPage);
			$("#currentPage").text(currPage);
			getCrop();
		}
	}else if(mark=="next"){
		if(currPage>=totalPages){	
			alert("没有下一页！");
			$("#next").attr("disabled",true);
		}else{
			currPage = currPage+1;
			$("#currPage").val(currPage);
			$("#currentPage").text(currPage);
			getCrop();
		}			
	}
}
			$(function(){
				$("#pageCount").val($('#pageSize option:selected').val());
			})


				//改变每页显示条数
				function currentPageToOne(){	
					currPage=1;	
					$("#currentPage").text(currPage);
					$("#currPage").val(currPage);
					$("#pageCount").val($('#pageSize option:selected').val());
					getCrop();
				}	
</script>
<title>Insert title here</title>
<style>
	.search { position:relative; width: 147px; }
	.search #i2 {
  border: 1px solid #ddd;
width: 120px;
line-height:20px;
height: 20px;
padding: 0 5px;
color: #333;
}


.search .searchButton {
  position: absolute;
  right: 15px;
  background: url(../images/002.png) -251px 0 no-repeat;
  width: 10px;
  height: 20px;
  text-indent: -9999px;
  border: none;
}
#i3{
	border: 1px solid #ddd;
	width: 120px;
	line-height:20px;
	height: 20px;
	padding: 0 5px;
	color: #333;
}
#i4{
	border: 1px solid #ddd;
	width: 120px;
	line-height:20px;
	height: 20px;
	padding: 0 5px;
	color: #333;
}
</style>
</head>
<body>

	<input type="hidden" value="" id="cid"/>
	<div id="login" class="easyui-dialog" title="系统登录"  style="width:300px;height:250px;padding:10px">
		<form id="loginForm" method="post">
			
			<table align="center" >
				<input id="i1" type="hidden" value=""/>
				
				<tr>
					<td>
						<div class="search">
							<input  id="i2" value='公司名称' onblur="doAction()" onfocus="if(this.value=='公司名称'){this.value=''}" style="color:#CCC;" class="easyui-validatebox" data-options="required:true"/> 
							<input id="btn1" class="searchButton" type="button" value="搜索" onclick="getCrop()"/>
						
						<div class="sercapacity3">
							<input type="button" value="确认" class="inconsbtns djque"  onclick="memberSure()"/>

								<div class="uldiv">
									<table cellpadding="0" cellspacing="0" style="width: 100%">
										<tr class="first">
											<td width="18%">选框</td>
											<td>编码</td>
											<td>公司名称</td>
										</tr>
										<tbody id="memberNames">
											<script type="text/html" id="memberList" name="memberList">
                   							{{each list as value index}}
												<tr>
													<td><input type="checkbox"  value={{value.cAccName}} name="memNamecheckbox" id="checkbox" class="memberCheck" onclick="selectOne(this)"></td>
													<td><input type="hidden" value={{value.cAccId}} name="memName" id="memName"/>{{value.cAccId}}</td>
													<td><input type="hidden" value={{value.cAccName}} name="memName" id="memName"/>{{value.cAccName}}</td>
												</tr>
											{{/each}}
                    	   				</script>
										</tbody>
										<tr>
											<input name = "currPage" id ="currPage" value="1" type="hidden">
											<input name = "totalPages" id ="totalPages" value="" type="hidden">
											<input name = "pageCount" id ="pageCount" value="" type="hidden">										
																				
											<td colspan="3">
												第 <span><label id="currentPage" >1</label></span> 页
												<span id="s2"><a href="#gotop" id="previous" onclick="fenye('previous')">上一页</a></span>
												<span id="s3"><a href="#gotop" id="next" onclick="fenye('next')">下一页</a></span>
												共<span><label id="ltotalPages"></label></span>页
												
													<select id="pageSize" name="store" onchange="currentPageToOne();">
														<option value="1" selected>1</option>	
														<option value="2">2</option>															
													</select>
												
											</td>
										</tr>
									</table>
								</div>
						</div>
						</div>
					</td>	
					
				</tr>
			
				<tr>	
					<td><input id="i3" name="username" value="请输入登陆账号" onblur="if(this.value==''){this.value='请输入登陆账号'}" onfocus="if(this.value=='请输入登陆账号'){this.value=''}" style="color:#CCC;" class="easyui-validatebox" data-options="required:true"/></td>
				</tr>
				<tr>
					
					<td><input id="i4" type="text" value="请输入登陆密码" onfocus="if(this.value=='请输入登陆密码') {this.value='';this.type='password';}" onblur="if(value=='') {value='请输入登陆密码'; this.type='text';}" style="color:#CCC;" class="easyui-validatebox" data-options="required:true"/></td>	
				</tr>
				<tr>
				
					<td><input id="shijian" value="" class="easyui-datebox" class="easyui-validatebox" data-options="required:true"></input></td>	
				</tr>
				<tr>
					<td><input id="btn1" type="button" value="立即登录" onclick="getValue()"/><input type="reset" value="重置"/></td>
				</tr>
			</table>
			
		</form>
		
	</div>
			<div id="tb3">
				<table id="tt">
				
				</table>
			</div>
			
			
</body>
</html>